home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / timing.arc / TIMERS.DOC < prev    next >
Text File  |  1987-10-01  |  6KB  |  125 lines

  1.     
  2.                   TIMING AND TIME-OUT SubPrograms for QUICKBASIC
  3.                   ==============================================      
  4.  
  5.          This document discusses:
  6.          
  7.                 -Programming with the timing routines DELAY & BGDELAY.
  8.  
  9.                 -Using TIMERS.BAS and INT86.OBJ in a user run-time library.
  10.     
  11.                 -BIOS interrupt 1Ah.
  12.  
  13.               
  14.          [This document and the software it describes were prepared by 
  15.          Ken Karp. You may reach me at the QuickBASIC conference on the 
  16.          MicroSellar BBS at (201) 239-1346 (NJ), or write to me at
  17.  
  18.                                 444 Sagamore Ave. 
  19.                                 Teaneck, NJ 07666
  20.  
  21.          You are free to do ANYTHING with these files as long as you do not 
  22.          (1) distribute any changes to them under my name, or (2) attribute 
  23.          such changes to me in any way.]
  24.  
  25.  
  26.  
  27.  
  28.  
  29.          PROGRAMMING WITH THE TIMING ROUTINES DELAY & BGDELAY
  30.          ====================================================
  31.  
  32.          (1) DELAY - this SubProgram is very simple in concept.  You merely 
  33.                  CALL DELAY (N!).  DELAY will loop until N! seconds have 
  34.                  passes.  NB: N! MUST be Single Precision (*!*)
  35.  
  36.          (2) BGDELAY - performs `background' timing while you perform some 
  37.                  other task of your own in `foreground'.  For instance:
  38.  
  39.                         PRINT "You have 10 seconds to answer."
  40.  
  41.                         STATUS%=0
  42.                         DO
  43.                                 GOSUB <do your own thing>
  44.                                 CALL BGDELAY (H.SCNDS!,TO.GO!.STATUS%)
  45.                                 Z$=INKEY$
  46.                         LOOP UNTIL Z$<>"" OR STATUS%=0
  47.  
  48.                         IF STATUS%=0 THEN
  49.                                 PRINT "Your time has expired!"
  50.                         ELSE
  51.                                 PRINT "You pressed ";z$
  52.                         END IF
  53.  
  54.                 will print the "10 seconds..." warning, and then loop until 
  55.                 EITHER a key is pressed OR 10 seconds (1000 hundredth 
  56.                 seconds) passes.  Notice that this gives you an opportunity 
  57.                 to do things on your own while you are waiting for one of 
  58.                 those two things to occur (thus the phrase `background' 
  59.                 timing).  Some of the things that you may want to do 
  60.                 include print the time remaining (like the example set 
  61.                 forth in TIMETEST.EXE), print the time of day, monitor a 
  62.                 communications port, blank out the screen after 5 minutes 
  63.                 of no typing, et.al. 
  64.  
  65.                 The parameters for BGDELAY are:
  66.  
  67.                 H.SCNDS! - hundredths of seconds you want to wait the 
  68.                         timeout occurs.
  69.                 TO.GO! - hundredths of seconds left to go (if you print 
  70.                         this out in the loop you will be `counting down' -- 
  71.                         see TIMETEST.BAS).
  72.                 STATUS% - must be set to 0 before the first call ONLY (before 
  73.                         entering the loop!); after that, TIMERS sets it 
  74.                         for you to test as follows: 1 indicates that 
  75.                         there is more time left, and 0 indicates that the 
  76.                         timeout has finally occurred.
  77.  
  78.          
  79.  
  80.          USING TIMERS.BAS IN A USER RUN-TIME LIBRARY
  81.          ===========================================
  82.  
  83.          The recommended, but not required, procedure for using TIMERS.BAS 
  84.          is to place the object file (TIMERS.OBJ) AND MicroSoft's INT86.OBJ 
  85.          into a MiscroSoft user run-time library.  The file TIMERS.EXE is
  86.          a user run-time library that contains these two object files.  
  87.  
  88.          The only restriction in usage is: IF YOU DO NOT USE TIMERS in a 
  89.          run-time library then you must not initiate a timing sequence in 
  90.          one program and CHAIN to another program to check on the timeout.  
  91.          This is due to the fact that TIMERS.OBJ maintains STATIC variables 
  92.          that must not be disrupted during the course of a single timeout 
  93.          cycle.  If you do not use CHAINing between calls, you will have no 
  94.          problem.
  95.  
  96.          If you are using the QuickBASIC v3.0 integrated environment you 
  97.          MUST place INT86.OBJ into a run time library.  TIMERS.OBJ may be 
  98.          placed into the same run-time library, or TIMERS.BAS may be 
  99.          $INCLUDEd into your source code.
  100.  
  101.          If you are using static library(s) (ie, .LIB files), you may add 
  102.          TIMERS.OBJ and INT86.OBJ to them, or you may add them as object 
  103.          modules at LINK time (eg, LINK MYPROG+TIMERS+INT86+...+,...).
  104.          
  105.  
  106.          NB:  INT86.OBJ (and INT86.ASM) are distributed with QuickBASIC 
  107.          v3.0.  INT86.OBJ may be called from a QuickBASIC v3.0 program to 
  108.          perform any 8086 interrupt.  TIMERS uses it to perform BIOS 
  109.          interrupt 1Ah (see below).
  110.  
  111.  
  112.  
  113.          BIOS INTERRUPT 1Ah
  114.          ==================
  115.  
  116.          BIOS interrupt 1Ah performs time of day functions.  TIMERS calls 
  117.          interrupt 1Ah with an argument of 0 in AH to obtain the clock 
  118.          ticks since midnight.  Although BIOS's change from one PC 
  119.          "compatible" computer to another, this particular call is very 
  120.          fundamental, and I would expect most (if not all) clones to 
  121.          service it.  If you find that TIMERS does not work as expected on 
  122.          your machine, and you wish to get it to work, you may contact me 
  123.          as outlined at the beginning of this document and I will try to 
  124.          help you.
  125.